import type {Command, CommandResult} from './command.type'

// 全局命令执行器（面向用户的API）
export class CommandExecutor {
  static async execute(command: Command, ...params: any[]): Promise<CommandResult> {
    try {
      const result = await command.handler(...params);
      return {
        success: true,
        data: result
      };
    } catch (error) {
      return {
        success: false,
        message: `Execution failed: ${error instanceof Error ? error.message : String(error)}`
      };
    }
  }
}